package com.hhxy.session.db;

import com.hhxy.session.pojo.Book;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author ghp
 * @date 2022/9/26
 * @Title
 * @description 用于模拟保存图书信息的数据库
 */
public class BookDB {
    private static Map<String, Book> books = new LinkedHashMap<String, Book>();
    static {
        books.put("1", new Book("1", "javaweb开发"));
        books.put("2", new Book("2", "jdbc开发"));
        books.put("3", new Book("3", "java基础"));
        books.put("4", new Book("4", "struts开发"));
        books.put("5", new Book("5", "spring开发"));
    }

    /**
     * 获取所有图书
     */
    public static Collection<Book> getAll() {
        return books.values();
    }

    /**
     * 根据id获取图书
     */
    public static Book getBook(String id) {
        return books.get(id);
    }

}
